package com.baicaoyuan.web.service;

import com.baicaoyuan.web.model.StockInDO;
import com.baicaoyuan.web.repository.StockInRepository;
import com.baicaoyuan.web.response.StockInResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述：
 *
 * @author 罗富祥
 * 创建时间： 2018/1/4
 */
@Service
public class StockInService {

    @Autowired
    StockInRepository stockInRepository;

    public List<StockInResponse> getStockIn(Long userId) {
        List<StockInDO> list = this.stockInRepository.getStockIn(userId);
        List<StockInResponse> result = new ArrayList<>();
        list.forEach(x -> {
            StockInResponse r = new StockInResponse();
            BeanUtils.copyProperties(x, r);
            result.add(r);
        });

        return result;
    }
}

